import java.nio.charset.IllegalCharsetNameException;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2025-02-03
 * Time: 20:35
 */
class MyQueue {

    private Stack<Integer> s1;
    private Stack<Integer> s2;

    public MyQueue() {
        s1 = new Stack<>();
        s2 = new Stack<>();
    }

    public void push(int x) {
        s1.push(x);
    }

    public int pop() {
        if (empty()){//模拟的队列是空的
            return -1;
        }
        if (s2.isEmpty()){
            //s1这个栈种的所有数据倒过来
            while (!s1.isEmpty()){
                s2.push(s1.pop());
            }
        }
        return s2.pop();
    }

    public int peek() {
        if (empty()){
            return -1;
        }
        if (s2.isEmpty()){
            while (!s1.isEmpty()){
                s2.push(s1.pop());
            }
        }
        return s2.peek();
    }

    public boolean empty() {
        return s1.isEmpty() && s2.empty();
    }
}
